package com.handpay.zztong.hp.accountcenter.activity;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.handpay.zztong.hp.R;
import com.handpay.zztong.hp.base.activity.ZZTongActivity;
import com.handpay.zztong.hp.bean.ActionBar;
import com.handpay.zztong.hp.login.activity.ModifyLoginPwdActivity;
import com.handpay.zztong.hp.utils.AccountUtils;



/**
 * 
 * 基本信息管理
 * @author 李国红
 * 
 */
public class BaseInfoActivity extends ZZTongActivity
{

	private TextView tv_account;
	private TextView tv_phone;
	private TextView tv_update_phone;
	private TextView tv_update_password;
	private LinearLayout ll_update_phone;
	private LinearLayout ll_update_password;
	String dayLimit=null;
	String monthLimit=null;
	String debitCardLimit=null;
	String creditCardLimit=null; 
	
	@Override
	protected void onCreate(Bundle savedInstanceState) 
	{
		this.setContentView(R.layout.activity_base_info);
		super.onCreate(savedInstanceState);		
		tv_account = (TextView) findViewById(R.id.tv_account);
		tv_phone = (TextView) findViewById(R.id.tv_phone);
		tv_update_phone = (TextView) findViewById(R.id.tv_update_phone);
		tv_update_password = (TextView) findViewById(R.id.tv_update_password);
		ll_update_phone=(LinearLayout)findViewById(R.id.ll_update_phone);
		ll_update_password=(LinearLayout)findViewById(R.id.ll_update_password);
		
		
//		Initialization();	
		ll_update_phone.setOnClickListener(this);
		tv_update_password.setOnClickListener(this);
		ll_update_password.setOnClickListener(this);
		tv_update_password.setOnClickListener(this);
	}

	@Override
	protected void onStart()
	{
		super.onStart();
		Initialization();
	}
	
	protected boolean isShownTabs() 
	{
		return false;
	}
	@Override
	public ActionBar getActivityActionBar() {
		return new ActionBar(this.getString(R.string.info_management_basic), true);
	}
	/***
	 * 初始化基本信息
	 */
	private void Initialization()
	{
		if(AccountUtils.getAccountName(this)!=null)
		  tv_account.setText(AccountUtils.getAccountName(this));
		if(AccountUtils.getAccountPhone(this)!=null){
			String temp = AccountUtils.getAccountPhone(this);
			String start = temp.substring(0, 3);
			String end = temp.substring(temp.length() - 4);
			tv_phone.setText(start + " **** " + end);		
		}
		if(AccountUtils.getAccountStatus(this)==AccountUtils.AccountStatus.CHECKING)
		{
			ll_update_phone.setVisibility(View.GONE);
		}
	}	
	
	
	@Override
	protected void onDestroy() 
	{
		super.onDestroy();
	}

	@Override
	public void onClick(View v) 
	{
		super.onClick(v);
		Intent intent=null;
        int i = v.getId();
        if (i == R.id.ll_update_phone) {//修改手机号
            intent = new Intent(this, PhoneNoModifyActivity.class);
            this.startActivity(intent);
//			 this.finish();

        } else if (i == R.id.ll_update_password || i == R.id.tv_update_password) {//修改登陆密码
            intent = new Intent(this, ModifyLoginPwdActivity.class);
            this.startActivity(intent);
//			  this.finish();

        }
	}
}
